package com.chapter2.basics;

import java.util.Random;

//选择排序法
public class Exe_2_2_2 {
	private static Random rand = new Random(48);
	private static int[] A = new int[100];

	public static void main(String[] args) {
		for (int i = 0; i < 100; i++) {
			A[i] = rand.nextInt(100);
		}
		for (int i = 0; i < A.length; i++) {
			System.out.println(i + ":" + A[i]);
		}

		int temp;
		for (int i = 0; i < 100; i++) {
			int indexLow = i;
			for (int j = i + 1; j < A.length; j++) {
				if (A[j] < A[indexLow]) {
					temp = A[indexLow];
					A[indexLow] = A[j];
					A[j] = temp;
				}
			}

		}
		for (int i = 0; i < A.length; i++) {
			System.out.println(i + ":" + A[i]);
		}
	}

}
